package cate.game.role.pvp.throne.msg;

import cate.common.util.XT;
import cate.game.GameBody;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBTB;
import cate.game.pvp.throne.data.ko.TBKoReport;

import java.util.List;

@ClientMsg(title = "我的淘汰赛最新战报 の 请求")
public class MyTBKoLatestReportReq implements MsgInput {


    @Override
    public void execute(GameBody game, ClientContext cc) {
        MyTBKoLatestReportResp resp = new MyTBKoLatestReportResp();
        List<TBKoReport> reports = game.pvp.throne.data.holder.findRoleReports(cc.getRole());
        if (XT.isNotBlank(reports)) {
            TBKoReport report = reports.get(reports.size() - 1);
            resp.round = report.round;
            resp.groupType = report.groupType;
            resp.matchGroup = report.matchGroup;
        }
        cc.getRole().sendNow(resp);
    }

    @Override
    public MsgConfig conf() {
        return MsgIdBTB.MY_KO_LATEST_INFO_REQ;
    }
}
